package com.ruoyi.web.hbxx.controller;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.hb.service.IChannelBuoyService;
import com.ruoyi.web.hbxx.domain.ChannelBuoyInfo;
import com.ruoyi.web.hbxx.service.IChannelBuoyInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 南方测绘航标数据Controller
 *
 * @author ruoyi
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/system/channelBuoy")
public class ChannelBuoyInfoController extends BaseController
{
    @Autowired
    private IChannelBuoyInfoService channelBuoyInfoService;

    @Autowired
    private IChannelBuoyService channelBuoyService;

    /**
     * 查询南方测绘航标数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:list')")
    @GetMapping("/list")
    public AjaxResult list(ChannelBuoyInfo channelBuoyInfo) throws IOException {
//        startPage();
        List<Map> list = channelBuoyService.getNavigationList();
        return AjaxResult.success(list);
    }

    /**
     * 导出南方测绘航标数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:export')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChannelBuoyInfo channelBuoyInfo)
    {
        List<ChannelBuoyInfo> list = channelBuoyInfoService.selectChannelBuoyInfoList(channelBuoyInfo);
        ExcelUtil<ChannelBuoyInfo> util = new ExcelUtil<ChannelBuoyInfo>(ChannelBuoyInfo.class);
        util.exportExcel(response, list, "南方测绘航标数据数据");
    }

    /**
     * 获取南方测绘航标数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(channelBuoyInfoService.selectChannelBuoyInfoById(id));
    }

    /**
     * 新增南方测绘航标数据
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:add')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelBuoyInfo channelBuoyInfo)
    {
        return toAjax(channelBuoyInfoService.insertChannelBuoyInfo(channelBuoyInfo));
    }

    /**
     * 修改南方测绘航标数据
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:edit')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelBuoyInfo channelBuoyInfo)
    {
        return toAjax(channelBuoyInfoService.updateChannelBuoyInfo(channelBuoyInfo));
    }

    /**
     * 删除南方测绘航标数据
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:remove')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(channelBuoyInfoService.deleteChannelBuoyInfoByIds(ids));
    }
}
